---
title: Setup for Docker
sidebarTitle: Docker
---

<iframe
    className="w-full h-96"
    width="628"
    height="286"
    src="https://www.youtube.com/embed/Bmuavy0MelQ"
    title="Deploy MindsDB using Docker"
    frameBorder="0"
    allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
    allowFullScreen
></iframe>

## Install Docker

Install Docker on your machine following [the instructions](https://docs.docker.com/install).

To make sure Docker is successfully installed on your machine, run a test container as follows:

```bash
docker run hello-world
```

You should see the `Hello from Docker!` message. Otherwise, check the [Docker's Get Started](https://www.docker.com/get-started) documentation.

<Warning>
**Docker for Mac users - RAM allocation issues**

By default, Docker for Mac allocates 2 GB of RAM, which is insufficient for deploying MindsDB with Docker. We recommend increasing the default RAM limit to 8 GB. Please refer to the [Docker Desktop for Mac users manual](https://docs.docker.com/desktop/mac/#resources) for more information on how to increase the allocated memory.
</Warning>

## Install MindsDB

<Tip>
**Choose one of the available [Docker images for MindsDB](https://hub.docker.com/r/mindsdb/mindsdb/tags)**

As MindsDB integrates with numerous [data sources](/integrations/data-overview) and [AI frameworks](/integrations/ai-overview), each integration requires a set of dependencies. Hence, MindsDB provides multiple Docker images for different tasks, as outlined below.

* `mindsdb/mindsdb:latest` (or `mindsdb/mindsdb`)
It is the lightweight Docker image of MindsDB that comes with [these integrations preloaded](https://github.com/mindsdb/mindsdb/blob/staging/default_handlers.txt).

* `mindsdb/mindsdb:lightwood`
It is the Docker image of MindsDB that comes with [these integrations](https://github.com/mindsdb/mindsdb/blob/staging/default_handlers.txt) and the Lightwood integration preloaded.

* `mindsdb/mindsdb:huggingface`
It is the Docker image of MindsDB that comes with [these integrations](https://github.com/mindsdb/mindsdb/blob/staging/default_handlers.txt) and the Hugging Face integration preloaded.
</Tip>

Run the command below, providing the selected Docker image, to start MindsDB in Docker and follow the logs:

```bash
docker run -p 47334:47334 -p 47335:47335 mindsdb/mindsdb
```

<Info>
Alternatively, if you run this command with the `detach` flag, it will return the container ID and not follow the logs:

```bash
docker run -d -p 47334:47334 -p 47335:47335 mindsdb/mindsdb
```
</Info>

<Tip>
If you would like to persist your models & configurations in the host machine, run the following commands:

```bash
mkdir mdb_data
docker run -p 47334:47334 -p 47335:47335 -v $(pwd)/mdb_data:/root/mdb_storage mindsdb/mindsdb
```

Let's analyze this command part by part:

-   `docker run` is a native Docker command used to start a container
-   `-p 47334:47334` publishes port 47334 to access MindsDB GUI and HTTP API
-   `-p 47335:47335` publishes port 47335 to access MindsDB MySQL API
-   `-v $(pwd)/mdb_data:/root/mdb_storage` maps the newly created folder `mdb_data` on the host machine to the `/root/mdb_storage` inside the container
-   `mindsdb/mindsdb` is the container we want to start
</Tip>

Now you can access the MindsDB editor by going to `127.0.0.1:47334` in your browser.

<p align="center">
  <img src="/assets/mindsdb-local-editor.png" />
</p>

## Install dependencies

MindsDB integrates with numerous data sources and AI frameworks. To use any of the integrations, you should enure that the required dependencies are installed in the Docker container.

Here is how to install the dependencies in the Docker container:

1. Run the MindsDB Docker container:
    ```bash
    docker run -d -p 47334:47334 -p 47335:47335 mindsdb/mindsdb
    ```

2. Start an interactive shell in the container:
    ```bash
    docker exec -it container-name sh
    ```

3. Install the dependencies:
    ```bash
    pip install mindsdb[handler_name]
    ```
    For example, run this command to install dependencies for the [OpenAI handler](https://github.com/mindsdb/mindsdb/tree/staging/mindsdb/integrations/handlers/openai_handler):
    ```bash
    pip install mindsdb[openai]
    ```

4. Exit the interactive shell:
    ```bash
    exit
    ```

5. Restart the container:
    ```bash
    docker restart container-name
    ```

## Configuration Options

### Default Configuration

The default configuration for MindsDB's Docker image is stored as a JSON code, as below.

```json
{
    "config_version": "1.4",
    "storage_dir": "/root/mdb_storage",
    "log": {
        "level": {
            "console": "ERROR",
            "file": "WARNING",
            "db": "WARNING"
        }
    },
    "debug": false,
    "integrations": {},
    "auth": {
        "username": "mindsdb",
        "password": "123"
    },
    "api": {
        "http": {
            "host": "127.0.0.1",
            "port": "47334"
        },
        "mysql": {
            "host": "127.0.0.1",
            "port": "47335",
            "database": "mindsdb",
            "ssl": true
        },
        "mongodb": {
            "host": "127.0.0.1",
            "port": "47336",
            "database": "mindsdb"
        }
    }
}
```

### Custom Configuration

To override the default configuration, you can mount a config file over `/root/mindsdb_config.json`, as below.

```bash
docker run -v mdb_config.json:/root/mindsdb_config.json mindsdb/mindsdb
```

## Known Issues

### #1

If you experience any issues related to MKL or your training process does not complete, please add the `MKL_SERVICE_FORCE_INTEL` environment variable, as below.

```bash
docker run -e MKL_SERVICE_FORCE_INTEL=1 -p 47334:47334 -p 47335:47335 mindsdb/mindsdb
```

## What's Next

Now that you installed and started MindsDB locally in your Docker container, go ahead and find out how to create and train a model using the [`CREATE MODEL`](/sql/create/model) statement.

Check out the [Use Cases](/use-cases/overview) section to follow tutorials that cover Large Language Models, Chatbots, Time Series, Classification, and Regression models, Semantic Search, and more.
